/**
 * Created by yuzhou on 2020/3/10.
 */

//vue获取数据
$(document).ready(function () {
    //获取
    //轮播图数据
    var data = new Vue({
        el:'#whole_box',
        data:{
            imglist:[],
            hot_recomm_txt:"",
            tab1:"信基沙溪(广州)",
            tab2:"信基豪泰(广州)",
            tab3:"信基沙溪(沈阳)",
            getImgUrl:"/market/getAdvantage",
            item_txt1:"",
            item_txt2:"",
            item_txt3:"",
            item_txt4:"",
            item_txt5:"",
            item_txt6:"",
            item_txt7:"",
            item_txt8:"",
            item_txt9:"",
            item_txt10:"",
            item_txt11:"",
            item_txt12:"",
            store_shaxi_list:[],
            store_haotai_list:[],
            store_shenyang_list:[],

            menu1:"",
            menu2:"",
            menu3:"",

            is_en:false,

            tab_num:1,
            main_pro_txt:"",
            search_txt:""
        },
        created: function(){
            this.getImg();              //定义方法编译完成后执行
            this.getShaXiGZData();
            this.getShaXiHTData();
            this.getShaXiSYData();
        },
        mounted:function(){
            var self = this;
            var language = localStorage.getItem("language");
            if(language == "cn"){
                self.is_en = false;
                self.changeToCn();
            }else{
                self.is_en = true;
                self.changeToEn()
            }

        },
        methods: {

            getImg: function(){
                var that = this;
                that.$http({           //调用接口
                    method:'post',
                    url:this.getImgUrl  //this指data
                }).then(function(response){  //接口返回数据

                    that.moredata = response.data;
                    console.log(JSON.stringify(that.moredata)+"xxx");
                    for(var i = 0;i<response.data.length;i++){
                        that.imglist.push("https://www.xinjisx.com"+"/wx/lubo/"+(response.data[i].pic_url)) ;
                        console.log(that.imglist[i]);
                    }
                },function(error){
                    console.log("请求出错");
                })
            },

            getShaXiGZData:function () {
                var self = this;
                $.ajax({
                    type:"GET",
                    url:"/market/getMarketByType",
                    data: {
                        type_id:1,
                        language:localStorage.getItem("language"),
                        page:1
                    },
                    dataType:"json",
                    success:function(res){
                        self.store_shaxi_list = res;
                    }
                });
            },

            getShaXiHTData:function () {
                var self = this;
                $.ajax({
                    type:"GET",
                    url:"/market/getMarketByType",
                    data: {
                        type_id:2,
                        language:localStorage.getItem("language"),
                        page:1
                    },
                    dataType:"json",
                    success:function(res){
                        self.store_haotai_list = res;
                    }
                });
            },

            getShaXiSYData:function () {
                var self = this;
                $.ajax({
                    type:"GET",
                    url:"/market/getMarketByType",
                    data: {
                        type_id:3,
                        language:localStorage.getItem("language"),
                        page:1
                    },
                    dataType:"json",
                    success:function(res){
                        self.store_shenyang_list = res;
                    }
                });
            },

            changeToCn:function () {
                var self = this;
                self.hot_recomm_txt="热门商家";
                self.tab1 = "信基沙溪(广州)";
                self.tab2 = "信基豪泰(广州)";
                self.tab3 = "信基沙溪(沈阳)";
                self.item_txt1 = "厨房设备及用品";
                self.item_txt2 = "陶瓷仿瓷餐具";
                self.item_txt3 = "玻璃制品";
                self.item_txt4 = "大堂客房用品";
                self.item_txt5 = "酒店布草";
                self.item_txt6 = "酒店家具";
                self.item_txt7 = "特色餐饮用品";
                self.item_txt8 = "不锈钢制品";
                self.item_txt9 = "咖啡饮品及材料";
                self.item_txt10 = "烘焙设备及物料";
                self.item_txt11 = "清洁劳保用品";
                self.item_txt12 = "综合配餐类";
                self.menu1 = "市场导购";
                self.menu2 = "动态资讯";
                self.menu3 = "联系我们";
                self.main_pro_txt = "主营";
                self.search_txt="搜索更多..";
            },

            changeToEn:function () {
                var self = this;
                self.hot_recomm_txt="Hot Recommended";
                self.tab1 = "XinJi ShaXi (Guangzhou)";
                self.tab2 = "XinJi Hotelex (Guangzhou)";
                self.tab3 = "XinJi Shaxi (Shenyang)";
                self.item_txt1 = "Kitchen Equipment and Supplies";
                self.item_txt2 = "Ceramic and Melamine Tablewares";
                self.item_txt3 = "Glassware Products";
                self.item_txt4 = "Hotel Lobby and Room Supplies";
                self.item_txt5 = "Hotel Linen";
                self.item_txt6 = "Hotel Furniture";
                self.item_txt7 = "Specialty Catering Supplies";
                self.item_txt8 = "Stainless Steel Products";
                self.item_txt9 = "Coffee and Drinking Equipments";
                self.item_txt10 = "Bakery Equipment and Supplies";
                self.item_txt11 = "Cleaning and Labor Supplies";
                self.item_txt12 = "Comprehensive Products";
                self.menu1 = "MarketShopping"+"\n"+"Guide";
                self.menu2 = "Dynamic"+"\n"+"Information";
                self.menu3 = "Contact Us";
                self.main_pro_txt = "Main Products";
                self.search_txt="Search More..";
            },

            tabGo:function (a) {
                if(a == 1){
                    window.location.href="#home";
                }else if(a == 2){
                    window.location.href="#profile";
                }else if(a == 3){
                    window.location.href="#messages";
                }

            },

            brandlistgo:function (a) {
                var self = this;
                window.location.href="/page/redirectBrandList?id="+a+"&market_type=999";
            },

            tabChange:function (a) {
                var self = this;
            },

            storDetail:function (a) {
                window.location.href = "/page/redirectStoreDeatil?id="+a;
            },
            goSearch:function () {
                window.location.href="/page/redirectSearch";
            }

        }

    });


});





